package no.ntnu.fp.gui.listeners;

import java.io.IOException;

import no.ntnu.fp.client.exceptions.NetworkException;
import no.ntnu.fp.gui.events.EmployeesRequestedEvent;
import no.ntnu.fp.services.EmployeeService;

public class EmployeesRequestedListener implements 
										GuiListener<EmployeesRequestedEvent> {

	private final EmployeeService employeeService;
	
	public EmployeesRequestedListener(EmployeeService employeeService) {
		this.employeeService = employeeService;
	}

	@Override
	public void handleEvent(EmployeesRequestedEvent evt) {
		try {
			employeeService.fetchAllEmployees();
		} catch (IOException e) {
			throw new NetworkException("Unable to fetch employees from server",
										e);
		}
	}

	@Override
	public boolean isLongRunningListener() {
		return false;
	}
}
